home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libcruft / ranlib / gennf.f < prev    next >
Text File  |  1996-07-19  |  2KB  |  76 lines

  1.       REAL FUNCTION gennf(dfn,dfd,xnonc)
  2.  
  3. C**********************************************************************
  4. C
  5. C     REAL FUNCTION GENNF( DFN, DFD, XNONC )
  6. C           GENerate random deviate from the Noncentral F distribution
  7. C
  8. C
  9. C                              Function
  10. C
  11. C
  12. C     Generates a random deviate from the  noncentral F (variance ratio)
  13. C     distribution with DFN degrees of freedom in the numerator, and DFD
  14. C     degrees of freedom in the denominator, and noncentrality parameter
  15. C     XNONC.
  16. C
  17. C
  18. C                              Arguments
  19. C
  20. C
  21. C     DFN --> Numerator degrees of freedom
  22. C             (Must be >= 1.0)
  23. C                              REAL DFN
  24. C      DFD --> Denominator degrees of freedom
  25. C             (Must be positive)
  26. C                              REAL DFD
  27. C
  28. C     XNONC --> Noncentrality parameter
  29. C               (Must be nonnegative)
  30. C                              REAL XNONC
  31. C
  32. C
  33. C                              Method
  34. C
  35. C
  36. C     Directly generates ratio of noncentral numerator chisquare variate
  37. C     to central denominator chisquare variate.
  38. C
  39. C**********************************************************************
  40. C     .. Scalar Arguments ..
  41.       REAL dfd,dfn,xnonc
  42. C     ..
  43. C     .. Local Scalars ..
  44.       REAL xden,xnum
  45.       LOGICAL qcond
  46. C     ..
  47. C     .. External Functions ..
  48.       REAL genchi,gennch
  49.       EXTERNAL genchi,gennch
  50. C     ..
  51. C     .. Executable Statements ..
  52.       qcond = dfn .LE. 1.0 .OR. dfd .LE. 0.0 .OR. xnonc .LT. 0.0
  53.       IF (.NOT. (qcond)) GO TO 10
  54.       WRITE (*,*) 'In GENNF - Either (1) Numerator DF <= 1.0 or'
  55.       WRITE (*,*) '(2) Denominator DF < 0.0 or '
  56.       WRITE (*,*) '(3) Noncentrality parameter < 0.0'
  57.       WRITE (*,*) 'DFN value: ',dfn,'DFD value: ',dfd,'XNONC value: ',
  58.      +  xnonc
  59.       CALL XSTOPX
  60.      + ('Degrees of freedom or noncent param our of range in GENNF')
  61.  
  62.    10 xnum = gennch(dfn,xnonc)/dfn
  63. C      GENNF = ( GENNCH( DFN, XNONC ) / DFN ) / ( GENCHI( DFD ) / DFD )
  64.       xden = genchi(dfd)/dfd
  65.       IF (.NOT. (xden.LE. (1.2E-38*xnum))) GO TO 20
  66.       WRITE (*,*) ' GENNF - generated numbers would cause overflow'
  67.       WRITE (*,*) ' Numerator ',xnum,' Denominator ',xden
  68.       WRITE (*,*) ' GENNF returning 1.0E38'
  69.       gennf = 1.0E38
  70.       GO TO 30
  71.  
  72.    20 gennf = xnum/xden
  73.    30 RETURN
  74.  
  75.       END
  76.